<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ include file="../include/laypublic.jsp"%>
<!DOCTYPE html>
<html>
<head>
<title>商务数据计划新增</title>
</head>
<style>

.pos-r {
	position: relative;
}

#file-import{
 	display:none;
}
#excel-import {
	margin-left: 1.65%;
	margin-bottom: 1.65%;
}

.fieldset {
	margin-top: 5px;
	margin-bottom: 0px
}

.layui-legend {
	background-color: #5fb878;
	font-size: 15px !important;
	width: 140px;
}

.layui-form-item {
	margin-bottom: 5px;
	clear: both;
	*zoom: 1;
}

.layui-form-label {
	width: 160px;
}

.right {
	float: right;
}

.width106 {
	width: 106px;
}

.width98 {
	width: 98px;
}

.width60 {
	width: 60px;
}

.biz-data-title{
	white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
    word-break: break-all;
    line-height:57px;
    height:57px;
}

.scroll-wraper {
	width: 89.65%;
	margin-left: 1.65%;
}

.scroll-wraper .scroll-layui-table {
	width: 100%;
	margin: 0 auto;
	background-color: transparent;
	overflow-x: auto;
	border-right: 1px solid #e6e6e6;
	box-shadow: 0 0 10px rgba(0, 0, 0, .12);
	display: flex;
	flex-direction: row;
}

.scroll-wraper .scroll-layui-table .scroll-layui-table-wraper-left {
	width: 24.05%;
	overflow-x: hidden;
	border-right: 1px solid #e6e6e6;
	box-shadow: 0 0 10px rgba(0, 0, 0, .12);
	background-color: transparent;
}

.scroll-wraper .scroll-layui-table .scroll-layui-table-wraper-left .layui-table {
	width: 400px;
}

.scroll-wraper .scroll-layui-table .scroll-layui-table-wraper-right {
	width: 75.95%;
	overflow-x: auto;
	overflow-y: hidden;
	position: relative;
}

.scroll-wraper .scroll-layui-table .scroll-layui-table-wraper-right .scroll-layui-table-content
{
	width: 3200px;
	display: block;
	position: absolute;
	left: -5px;
	top: 0px;
}

.scroll-layui-table .layui-table {
	margin: 0px;
}

</style>
<script type="text/html" id="bizDataRpt" data-control='bizDataTitleBox' >
	<tr id="subBtnRow{% index}" class="biz-data-title"   ><td title="{% itemName}" >{% itemName}
<input type="hidden" name="bizDataDetails[{% index}].itemName" value="{% itemName}"   >
</td></tr>
</script>
<script type="text/html" id="bizDataDetailRpt" data-control='bizDataMxBox' >
<tr id="subRow{% index}" >
<td><input type="text" name="bizDataDetails[{% index}].earlyAddup" maxlength=15 value="{% earlyAddup}"
	autocomplete="off"  lay-verify="required|floatNumber"
	class="layui-input decimal" placeholder="前期累计" /></td>
<td><input type="text" name="bizDataDetails[{% index}].januaryValues" maxlength=15 value="{% januaryValues}"
	autocomplete="off" lay-verify="required|floatNumber"
	class="layui-input decimal" placeholder="一月"  /></td>
<td><input type="text" name="bizDataDetails[{% index}].februaryValues" maxlength=15 value="{% februaryValues}"
	autocomplete="off" lay-verify="required|floatNumber"
	class="layui-input decimal" placeholder="二月"  /></td>
<td><input type="text" name="bizDataDetails[{% index}].marchValues" maxlength=15 value="{% marchValues}"
	autocomplete="off" lay-verify="required|floatNumber"
	class="layui-input decimal"  placeholder="三月 " /></td>
<td><input type="text" name="bizDataDetails[{% index}].aprilValues" maxlength=15 value="{% aprilValues}"
	autocomplete="off" lay-verify="required|floatNumber"
	class="layui-input decimal"  placeholder="四月 "  /></td>
<td><input type="text" name="bizDataDetails[{% index}].mayValues" maxlength=15 value="{% mayValues}"
	autocomplete="off" lay-verify="required|floatNumber"
	class="layui-input decimal"  placeholder="五月 "  /></td>
<td><input type="text" name="bizDataDetails[{% index}].juneValues" maxlength=15 value="{% juneValues}"
	autocomplete="off" lay-verify="required|floatNumber"
	class="layui-input decimal" placeholder="六月 " /></td>
<td><input type="text" name="bizDataDetails[{% index}].julyValues" maxlength=15  value="{% julyValues}"
	autocomplete="off" lay-verify="required|floatNumber"
	class="layui-input decimal" placeholder="七月 " /></td>
<td><input type="text" name="bizDataDetails[{% index}].augustValues" maxlength=15 value="{% augustValues}"
	autocomplete="off" lay-verify="required|floatNumber"
	class="layui-input decimal" placeholder="八月 " /></td>
<td><input type="text" name="bizDataDetails[{% index}].septemberValues" maxlength=15 value="{% septemberValues}"
	autocomplete="off" lay-verify="required|floatNumber"
	class="layui-input decimal" placeholder="九月 "    /></td>
<td><input type="text" name="bizDataDetails[{% index}].octoberValues" maxlength=15 value="{% octoberValues}"
	autocomplete="off" lay-verify="required|floatNumber"
	class="layui-input decimal" placeholder="十月 " /></td>
<td><input type="text" name="bizDataDetails[{% index}].novemberValues" maxlength=15 value="{% novemberValues}"
	autocomplete="off" lay-verify="required|floatNumber"
	class="layui-input decimal" placeholder="十一月 "  /></td>
<td><input type="text"  name="bizDataDetails[{% index}].decemberValues" maxlength=15 value="{% decemberValues}"
	autocomplete="off" lay-verify="required|floatNumber"
	class="layui-input decimal" placeholder="十二月 " /></td>
<td><input type="text" name="bizDataDetails[{% index}].yearAddup" maxlength=15 value="{% yearAddup}"
	autocomplete="off" lay-verify="required|floatNumber"
	class="layui-input decimal" placeholder="本年累计 " /></td>
<td><input type="text" name="bizDataDetails[{% index}].totalAddup" maxlength=15 value="{% totalAddup}"
	autocomplete="off" lay-verify="required|floatNumber"
	class="layui-input decimal " placeholder="开累 " /></td>
</tr>
</script>
<body>
	<div class="layui-fluid" >
		<div class="layui-card" >
			<div class="layui-tab-item layui-show" >
				<div style="padding-top: 15px;">&nbsp;</div>
				<form class="layui-form" id="addInfo_form"
					lay-filter="add_info_from">
					<fieldset class="layui-elem-field layui-field-title fieldset"
						id="baseInfo">
						<legend class="layui-btn layui-legend"
							style="text-align: left; cursor: default;">项目基础信息 ></legend>
						<div style="margin-top: 20px">
							<div class="layui-form-item">
								<div class="layui-inline">
									<label class="layui-form-label">申请公司</label>
									<div class="layui-input-inline">
										<input type="hidden" name="effectOrgId" value="${bindOrgId}">
										<input type="text" value="${bindOrgName}"   style="border: 0px;"
											readonly="readonly" class="layui-input">
									</div>
								</div>
								<div class="layui-inline">
									<label class="layui-form-label">申请部门</label>
									<div class="layui-input-inline">
										<input type="hidden" name="effectDeptId" value="${bindDeptId}">
										<input type="text" value="${bindDeptName}"
											style="border: 0px;" readonly="readonly" class="layui-input">
									</div>
								</div>
								<div class="layui-inline">
									<label class="layui-form-label">申请人</label>
									<div class="layui-input-inline">
										<input type="hidden" name="effectStaffApplyId"
											readonly="readonly"
											value="${SESSION_KEY_USER_DETAIL.hrStaffId }"> <input
											type="text" name="staffName" value="${staffName }"
											readonly="readonly" style="border: 0px" class="layui-input">
									</div>
								</div>
							</div>
							<div class="layui-form-item">
								<div class="layui-inline">
									<label class="layui-form-label">项目名称</label>
									<div class="layui-input-inline">
										<select name="id" id="add_select_proId" lay-verify="required" lay-filter="add_select_proId" lay-search >
											<option value="">请选择</option>
											<c:if test="${not empty proContractList}" >
												<c:forEach items="${proContractList}" var="proNames">
													<option value="${proNames.id}" proCode="${proNames.proCode}">${proNames.proName}</option>
												</c:forEach>
											</c:if>
										</select> 
										<input type="hidden" id="proCode" name="proCode">
										<input type="hidden" id="proName" name="proName">
									</div>
								</div>
								<div class="layui-inline">
									<label class="layui-form-label">计划年份</label>
									<div class="layui-input-inline">
										<input type="text" class="layui-input" id="sent-laydate-year" lay-verify="required" readonly name="planYear" >
									</div>
								</div>
							</div>
						</div>
					</fieldset>
					<fieldset class="layui-elem-field layui-field-title fieldset">
						<legend class="layui-btn layui-legend pos-r"
							style="text-align: left; cursor: default;width:150px;">商务数据计划 > </legend>
						<div style="margin-top: 20px;">
							<button type="button" class="layui-btn" id="excel-import">Excel导入</button>
							<input type="file" id="file-import"  />
							<div class="scroll-wraper">
								<div class="scroll-layui-table">
									<div class="scroll-layui-table-wraper-left">
										<table class="layui-table">
											<colgroup>
												<col width="200">
											</colgroup>
											<thead>
												<tr>
													<th>名称</th>
												</tr>
											</thead>
											<tbody id="bizDataTitleBox" ></tbody>
										</table>
									</div>
									<div class="scroll-layui-table-wraper-right" >
										<div class=" scroll-layui-table-content" >
											<table class="layui-table" >
												<colgroup>
													<col width="70" >
													<col width="110">
													<col width="110">
													<col width="110">
													<col width="110">
													<col width="110">
													<col width="110">
													<col width="110">
													<col width="110">
													<col width="110">
													<col width="110">
													<col width="110">
													<col width="110">
													<col width="110">
													<col width="110">
												</colgroup>
												<thead>
													<tr>
														<th>前期累计（元）</th>
														<th>一月（元）</th>
														<th>二月（元）</th>
														<th>三月（元）</th>
														<th>四月（元）</th>
														<th>五月（元）</th>
														<th>六月（元）</th>
														<th>七月（元）</th>
														<th>八月（元）</th>
														<th>九月（元）</th>
														<th>十月（元）</th>
														<th>十一月（元）</th>
														<th>十二月（元）</th>
														<th>本年累计（元）</th>
														<th>开累（元）</th>
													</tr>
												</thead>
												<tbody id="bizDataMxBox" ></tbody>
											</table>
										</div>
									</div>
								</div>
							</div>

						</div>
					</fieldset>

					<div class="layui-form-item"
						style="position: fixed ! important; right: 30px; bottom: 45%; z-index: 10000;">
						<div class="layui-input-block">
							<button
								class="layui-btn layui-bg-blue layui-btn-normal layui-btn-lg  layui-btn-radius"
								type="button" lay-submit lay-filter="addInfo_form_submit"
								id="addInfo_form_submit">
								<i class="layui-icon layui-icon-ok layuiadmin-button-btn"></i>
								提交
							</button>
						</div>
					</div>
				</form>
				<div class="layui-form" lay-filter="add_from" id="add_from" style="padding: 20px 30px 0 0;display:none">
				    <div class="layui-form-item">
		                    <div class="layui-input-block">导入数据成功，点击确认提交审批
		                    </div>
				    </div>
				    <div class="layui-form-item layui-hide">
				      <input type="button" lay-submit lay-filter="add_from_submit" id="add_from_submit" value="确认">
				    </div>
				</div>
			</div>
		</div>
	</div>

	<script>
	var itemData=[
{itemName: "1. 合同履约投资",earlyAddup: "0", januaryValues: "0", februaryValues: "0", marchValues: "0", aprilValues: "0", mayValues: "0",juneValues: "0", julyValues: "0", augustValues: "0", septemberValues: "0", octoberValues: "0", novemberValues: "0",decemberValues: "0", yearAddup: "0", totalAddup: "0"},
{itemName: "1.1合同应付政府代付费",earlyAddup: "0", januaryValues: "0", februaryValues: "0", marchValues: "0", aprilValues: "0", mayValues: "0",juneValues: "0", julyValues: "0", augustValues: "0", septemberValues: "0", octoberValues: "0", novemberValues: "0",decemberValues: "0", yearAddup: "0", totalAddup: "0"},
{itemName: "1.2 合同应付前期费",earlyAddup: "0", januaryValues: "0", februaryValues: "0", marchValues: "0", aprilValues: "0", mayValues: "0",juneValues: "0", julyValues: "0", augustValues: "0", septemberValues: "0", octoberValues: "0", novemberValues: "0",decemberValues: "0", yearAddup: "0", totalAddup: "0"},
{itemName: "1.3 合同政府口径建安费用",earlyAddup: "0", januaryValues: "0", februaryValues: "0", marchValues: "0", aprilValues: "0", mayValues: "0",juneValues: "0", julyValues: "0", augustValues: "0", septemberValues: "0", octoberValues: "0", novemberValues: "0",decemberValues: "0", yearAddup: "0", totalAddup: "0"},
{itemName: "1.4 合同应付专业设备采购",earlyAddup: "0", januaryValues: "0", februaryValues: "0", marchValues: "0", aprilValues: "0", mayValues: "0",juneValues: "0", julyValues: "0", augustValues: "0", septemberValues: "0", octoberValues: "0", novemberValues: "0",decemberValues: "0", yearAddup: "0", totalAddup: "0"},
{itemName: "2. 实际投资",earlyAddup: "0", januaryValues: "0", februaryValues: "0", marchValues: "0", aprilValues: "0", mayValues: "0",juneValues: "0", julyValues: "0", augustValues: "0", septemberValues: "0", octoberValues: "0", novemberValues: "0",decemberValues: "0", yearAddup: "0", totalAddup: "0"},
{itemName: "2.1 政府代付费",earlyAddup: "0", januaryValues: "0", februaryValues: "0", marchValues: "0", aprilValues: "0", mayValues: "0",juneValues: "0", julyValues: "0", augustValues: "0", septemberValues: "0", octoberValues: "0", novemberValues: "0",decemberValues: "0", yearAddup: "0", totalAddup: "0"},
{itemName: "2.2 项目前期费",earlyAddup: "0", januaryValues: "0", februaryValues: "0", marchValues: "0", aprilValues: "0", mayValues: "0",juneValues: "0", julyValues: "0", augustValues: "0", septemberValues: "0", octoberValues: "0", novemberValues: "0",decemberValues: "0", yearAddup: "0", totalAddup: "0"},
{itemName: "2.3 总包口径建安费用",earlyAddup: "0", januaryValues: "0", februaryValues: "0", marchValues: "0", aprilValues: "0", mayValues: "0",juneValues: "0", julyValues: "0", augustValues: "0", septemberValues: "0", octoberValues: "0", novemberValues: "0",decemberValues: "0", yearAddup: "0", totalAddup: "0"},
{itemName: "2.4 专业设备采购",earlyAddup: "0", januaryValues: "0", februaryValues: "0", marchValues: "0", aprilValues: "0", mayValues: "0",juneValues: "0", julyValues: "0", augustValues: "0", septemberValues: "0", octoberValues: "0", novemberValues: "0",decemberValues: "0", yearAddup: "0", totalAddup: "0"},
{itemName: "3. 投资付款",earlyAddup: "0", januaryValues: "0", februaryValues: "0", marchValues: "0", aprilValues: "0", mayValues: "0",juneValues: "0", julyValues: "0", augustValues: "0", septemberValues: "0", octoberValues: "0", novemberValues: "0",decemberValues: "0", yearAddup: "0", totalAddup: "0"},
{itemName: "3.1 支付政府代付费",earlyAddup: "0", januaryValues: "0", februaryValues: "0", marchValues: "0", aprilValues: "0", mayValues: "0",juneValues: "0", julyValues: "0", augustValues: "0", septemberValues: "0", octoberValues: "0", novemberValues: "0",decemberValues: "0", yearAddup: "0", totalAddup: "0"},
{itemName: "3.2 支付项目前期费",earlyAddup: "0", januaryValues: "0", februaryValues: "0", marchValues: "0", aprilValues: "0", mayValues: "0",juneValues: "0", julyValues: "0", augustValues: "0", septemberValues: "0", octoberValues: "0", novemberValues: "0",decemberValues: "0", yearAddup: "0", totalAddup: "0"},
{itemName: "3.3 支付总包口径建安费用",earlyAddup: "0", januaryValues: "0", februaryValues: "0", marchValues: "0", aprilValues: "0", mayValues: "0",juneValues: "0", julyValues: "0", augustValues: "0", septemberValues: "0", octoberValues: "0", novemberValues: "0",decemberValues: "0", yearAddup: "0", totalAddup: "0"},
{itemName: "3.4 支付专业设备采购",earlyAddup: "0", januaryValues: "0", februaryValues: "0", marchValues: "0", aprilValues: "0", mayValues: "0",juneValues: "0", julyValues: "0", augustValues: "0", septemberValues: "0", octoberValues: "0", novemberValues: "0",decemberValues: "0", yearAddup: "0", totalAddup: "0"},
{itemName: "4. 投资回购",earlyAddup: "0", januaryValues: "0", februaryValues: "0", marchValues: "0", aprilValues: "0", mayValues: "0",juneValues: "0", julyValues: "0", augustValues: "0", septemberValues: "0", octoberValues: "0", novemberValues: "0",decemberValues: "0", yearAddup: "0", totalAddup: "0"},
{itemName: "4.1 回购年金本金收回",earlyAddup: "0", januaryValues: "0", februaryValues: "0", marchValues: "0", aprilValues: "0", mayValues: "0",juneValues: "0", julyValues: "0", augustValues: "0", septemberValues: "0", octoberValues: "0", novemberValues: "0",decemberValues: "0", yearAddup: "0", totalAddup: "0"},
{itemName: "4.2 回购年金利息收入",earlyAddup: "0", januaryValues: "0", februaryValues: "0", marchValues: "0", aprilValues: "0", mayValues: "0",juneValues: "0", julyValues: "0", augustValues: "0", septemberValues: "0", octoberValues: "0", novemberValues: "0",decemberValues: "0", yearAddup: "0", totalAddup: "0"},
{itemName: "5. 经营利润",earlyAddup: "0", januaryValues: "0", februaryValues: "0", marchValues: "0", aprilValues: "0", mayValues: "0",juneValues: "0", julyValues: "0", augustValues: "0", septemberValues: "0", octoberValues: "0", novemberValues: "0",decemberValues: "0", yearAddup: "0", totalAddup: "0"},
{itemName: "5.1 建安毛利",earlyAddup: "0", januaryValues: "0", februaryValues: "0", marchValues: "0", aprilValues: "0", mayValues: "0",juneValues: "0", julyValues: "0", augustValues: "0", septemberValues: "0", octoberValues: "0", novemberValues: "0",decemberValues: "0", yearAddup: "0", totalAddup: "0"},
{itemName: "5.2 二三次经营利润",earlyAddup: "0", januaryValues: "0", februaryValues: "0", marchValues: "0", aprilValues: "0", mayValues: "0",juneValues: "0", julyValues: "0", augustValues: "0", septemberValues: "0", octoberValues: "0", novemberValues: "0",decemberValues: "0", yearAddup: "0", totalAddup: "0"},
{itemName: "5.2.1 建设期二三次经营利润",earlyAddup: "0", januaryValues: "0", februaryValues: "0", marchValues: "0", aprilValues: "0", mayValues: "0",juneValues: "0", julyValues: "0", augustValues: "0", septemberValues: "0", octoberValues: "0", novemberValues: "0",decemberValues: "0", yearAddup: "0", totalAddup: "0"},
{itemName: "5.2.2 针对运维期银行利率倒挂及自有资金利息亏损的经营利润",earlyAddup: "0", januaryValues: "0", februaryValues: "0", marchValues: "0", aprilValues: "0", mayValues: "0",juneValues: "0", julyValues: "0", augustValues: "0", septemberValues: "0", octoberValues: "0", novemberValues: "0",decemberValues: "0", yearAddup: "0", totalAddup: "0"},
{itemName: "5.3 项目运维利润",earlyAddup: "0", januaryValues: "0", februaryValues: "0", marchValues: "0", aprilValues: "0", mayValues: "0",juneValues: "0", julyValues: "0", augustValues: "0", septemberValues: "0", octoberValues: "0", novemberValues: "0",decemberValues: "0", yearAddup: "0", totalAddup: "0"},
{itemName: "5.4 资金运营利润",earlyAddup: "0", januaryValues: "0", februaryValues: "0", marchValues: "0", aprilValues: "0", mayValues: "0",juneValues: "0", julyValues: "0", augustValues: "0", septemberValues: "0", octoberValues: "0", novemberValues: "0",decemberValues: "0", yearAddup: "0", totalAddup: "0"},
{itemName: "5.5 运维期亏损计提准备金",earlyAddup: "0", januaryValues: "0", februaryValues: "0", marchValues: "0", aprilValues: "0", mayValues: "0",juneValues: "0", julyValues: "0", augustValues: "0", septemberValues: "0", octoberValues: "0", novemberValues: "0",decemberValues: "0", yearAddup: "0", totalAddup: "0"},
{itemName: "5.5.1 运维期运维费亏损",earlyAddup: "0", januaryValues: "0", februaryValues: "0", marchValues: "0", aprilValues: "0", mayValues: "0",juneValues: "0", julyValues: "0", augustValues: "0", septemberValues: "0", octoberValues: "0", novemberValues: "0",decemberValues: "0", yearAddup: "0", totalAddup: "0"},
{itemName: "5.5.2 运维期利息亏损",earlyAddup: "0", januaryValues: "0", februaryValues: "0", marchValues: "0", aprilValues: "0", mayValues: "0",juneValues: "0", julyValues: "0", augustValues: "0", septemberValues: "0", octoberValues: "0", novemberValues: "0",decemberValues: "0", yearAddup: "0", totalAddup: "0"},
{itemName: "5.5.3 自有资金利息亏损",earlyAddup: "0", januaryValues: "0", februaryValues: "0", marchValues: "0", aprilValues: "0", mayValues: "0",juneValues: "0", julyValues: "0", augustValues: "0", septemberValues: "0", octoberValues: "0", novemberValues: "0",decemberValues: "0", yearAddup: "0", totalAddup: "0"}];
						
	var dateFtt = function(fmt, date){
		  var o = {
		    'M+': date.getMonth() + 1, //月份
		    'd+': date.getDate(), //日
		    'h+': date.getHours(), //小时
		    'm+': date.getMinutes(), //分
		    's+': date.getSeconds(), //秒
		    'q+': Math.floor((date.getMonth() + 3) / 3), //季度
		    S: date.getMilliseconds() //毫秒
		  };
		  if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (date.getFullYear() + '').substr(4 - RegExp.$1.length));
		  for (var k in o)
		    if (new RegExp('(' + k + ')').test(fmt))
		      fmt = fmt.replace(RegExp.$1, RegExp.$1.length == 1 ? o[k] : ('00' + o[k]).substr(('' + o[k]).length));
		  return fmt;
		};
		var requestFilter = {
		  toDate: function(timeStr) {
		    var time = timeStr.substr(0, 10);
		    return dateFtt('yyyy-MM-dd hh:mm:ss', new Date(time * 1000));
		  },
		  runStatus: function(text) {
		    var data = '';
		    switch (text) {
		      case 'FAILED':
		        data = '审批失败';
		        break;
		      default:
		        data = '未知';
		        break;
		    }
		    return data;
		  }
	};
	String.prototype.repeat = function(model, sepa) {
	  sepa = !sepa ? '' : sepa;
	  var thisTempArray = [];
	  for (var m = 0, n = model.length; m < n; m++) {
	    thisTempArray.push(
	      this.replace(/\{\%[\s]*(\w+)[\s]*(\|?)([\s]*)(\w*)([\s]*)\}/g, function(s, i) {
	        var key = s.replace(/[^\w\|]*/g, '');
	        if (key.indexOf('|') != -1) {
	          let key_name = key.split('|')[0].trim();
	          let fun_name = key.split('|')[1].trim();
	          return requestFilter[fun_name](model[m][key_name]);
	        }
	        if(key=='index'){
	        	return m;
	        }
	        return model[m][key] ? model[m][key] : '--';
	      })
	    );
	  }
	  return thisTempArray.join(sepa);
	};		
	
		//静态资源路径前缀
		var staticPath = '${fileHttpPre}';
		var stateJSON = <infopub:dicJson groupNo="A00010028" />;
		
		layui.config({
					base : '${ctx}/resources/layuiadmin/' //静态资源所在路径
				})
				.extend({
					index : 'lib/index' //主入口模块
				})
				.use(['index', 'set', 'upload', 'element', 'laydate' ],function() {
							var $ = layui.$, form = layui.form, element = layui.element, laydate = layui.laydate, upload = layui.upload;
							(function($) {
							  $.fn.repeater = function(options) {
							    let defaults = {
							      control: null,
							      onItemDataBound: null,
							      data: null,
							      debug: false
							    };
							    let opt = $.extend(defaults, options);
							    let $result;
							    this.each(function() {
							      var _this = $(this),
							        _id = this.id;
							      if (opt.debug) {
							        console.info('ID is the jquery.repeater plug-in for ' + _id);
							      }
							      $result = opt.control || $("#"+_this.data('control'));
							      var data = opt.data;
							        if ($.isArray(data) == false) {
							          return false;
							        }
							        if (data.length > 0) {
							          data = typeof opt.onItemDataBound == 'function' ? opt.onItemDataBound(data) : data;
							          var _html = _this.html();
							          if (_html!='') {
							        	 $result.empty().append($(_html.repeat(data)));
							          }
							        } 
							    });
							    return $result;
							  };
							})($);							
							
							$('#bizDataRpt,#bizDataDetailRpt').repeater({
								data:itemData
							});					
							
							$("#bizDataMxBox").on('blur','.decimal',function(){
								isNumerFloat(this);
								arabiaToCN(this,1);
							})
							
							laydate.render({
							      elem: '#sent-laydate-year'
							      ,type: 'year'
						 		});
							
							// 正则校验
							form
									.verify({
										//验证汉字
										CHS : [ /^[\u0391-\uFFE5]+$/, '只能输入汉字' ],
										//大于0的正整数
										intNumber : [ /^[1-9]\d*$/, '请输入正确的数字' ],
										//数字只能有两位小数
										floatNumber : [
												/^([-]?)([0-9](\d+)?(\.\d{1,2})?$)|(^\d\.\d{1,2}$)/,
												'请输入正确的数字' ],
										//数字大于0，并只能有两位小数
										floatAmount : [
												/^([0-9](\d+)?(\.\d{1,2})?$)|(^\d\.\d{1,2}$)/
												//var pattern=/^((\d+\.\d*[1-9]\d{1})|(\d*[1-9]\d*\.\d{2}))$/; 
												, '请输入正确的数字' ]
									});
							//上传附件
							upload.render({
										elem : '#excel-import',
										url : basePath + '/bizData/importExcel/',
										accept : 'file',
										acceptMime : 'application/vnd.ms-excel,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
										before : function(obj) { //obj参数包含的信息
											layer.load(); //上传loading
										},
										done : function(res) {
											//如果上传失败
											if (res.code > 0) {
												layer.closeAll('loading'); //关闭loading
												return layer.msg(res.msg, {
													icon : 7
												});
											}
											//上传完毕
											if (res.entity != null && res.entity.length > 0) {
												$('#bizDataRpt,#bizDataDetailRpt').repeater({
													data:res.entity
												});
											}
											layer.closeAll('loading'); //关闭loading
										},
										error : function() {
											layer.closeAll('loading'); //关闭loading
											//上传失败
											layer.msg("上传失败，请稍后再试~", {
												icon : 7
											});
										}
									});


							//监听提交
							form.on(
											'submit(addInfo_form_submit)',
											function(data) {
												$("#addInfo_form_submit")
														.removeAttr(
																"lay-submit")
														.removeClass(
																"layui-bg-blue")
														.addClass(
																"layui-btn-disabled");
												layer.load();
												//提交 Ajax 成功后，静态更新表格中的数据
												$.ajax({
															type : 'post',
															url : basePath
																	+ '/bizData/save',
															data : $(
																	'#addInfo_form')
																	.serialize(),
															success : function(
																	result) {
																if (result.success) {
																	layer
																			.closeAll('loading'); //关闭loading
																	layer
																			.msg(
																					'提交单据成功~',
																					{
																						icon : 1
																					});
																	//两秒后关闭当前页面
																	setTimeout(
																			function() {
																				/**
																				 * 查找父菜单，并刷新
																				 */
																				var topDoc = $(window.top.document);
																				var path = basePath
																						+ '/bizData/list';
																				// 获取页面名称
																				var name = topDoc
																						.find(
																								".layui-nav-item [lay-href^='"
																										+ path
																										+ "']")
																						.text();
																				if (name == ''
																						|| name == null) {
																					name = '商务数据';
																				}
																				window.parent.layui.index
																						.openTabsPage(
																								path,
																								name);
																				var iframe = window.parent.layui.admin
																						.tabsBody(
																								window.parent.layui.admin.tabsPage.index)
																						.find(
																								".layadmin-iframe");
																				iframe[0].contentWindow.location
																						.reload(true);

																				/**
																				 * 关闭当前页
																				 */
																				var currPath = basePath
																						+ '/bizData/add';
																				var layid = topDoc
																						.find(
																								"li[lay-id^='"
																										+ currPath
																										+ "']")
																						.attr(
																								'lay-id');
																				window.parent.layui.element
																						.tabDelete(
																								'layadmin-layout-tabs',
																								layid);//关闭当前页
																			},
																			2000);
																} else {
																	layer
																			.closeAll('loading'); //关闭loading
																	$(
																			"#addInfo_form_submit")
																			.removeClass(
																					"layui-btn-disabled")
																			.addClass(
																					"layui-bg-blue")
																			.attr(
																					"lay-submit",
																					"");
																	layer
																			.msg(
																					result.msg,
																					{
																						icon : 7
																					});
																}
															}
														});
											});
							// data-type事件
							$('.layui-btn.layuiadmin-btn-admin').on(
									'click',
									function() {
										var type = $(this).data('type');
										active[type] ? active[type].call(this)
												: '';
									});

							//新增-项目名select监听
							form.on('select(add_select_proId)', function(data) {
								var proId = data.value;
								if (proId == '' || proId == null) {
									layer.msg('请选择项目名称', {
										icon : 1
									});
									return;
								}
								var proName = $("#add_select_proId").find("option:selected").text().trim();
								$("#proName").val(proName);
								var proCode = $("#add_select_proId").find("option:selected").attr("procode");
								$("#proCode").val(proCode);
							});

						});
		
		//验证金额
		function isNumerFloat(obj){
			var $ = layui.$;
			if (obj.value == '' || obj.value == null) {
				return;
			}
			var rgx = /^([-]?)([0-9](\d+)?(\.\d{1,2})?$)|(^\d\.\d{1,2}$)/;
			var boolrgx = rgx.test(obj.value);// true 
			if (!boolrgx){
				obj.value=0;
				layer.msg('请输入正确数字，且保留两位小数！');
				return;
			}
		}

	</script>
</body>
</html>

